package wangxu

import (
	"context"
	"github.com/beherochuling/beesoft_api/app/dao"
	"github.com/beherochuling/beesoft_api/app/model/entity"
)

func NewLetsviewUser(ctx context.Context) *letsviewUser {
	return &letsviewUser{
		ctx: ctx,
	}
}

type letsviewUser struct {
	ctx context.Context
}

func (r *letsviewUser) GetByCode(code uint64) *entity.LetsviewUsers {
	var item *entity.LetsviewUsers

	err := dao.LetsviewUsers.Ctx(r.ctx).
		Where(dao.LetsviewUsers.Columns().Code, code).
		Scan(&item)
	if err != nil {
		panic(err)
	}

	return item
}
func (r *letsviewUser) GetByAuth(auth string) *entity.LetsviewUsers {
	var item *entity.LetsviewUsers

	err := dao.LetsviewUsers.Ctx(r.ctx).
		Where(dao.LetsviewUsers.Columns().Auth, auth).
		Scan(&item)
	if err != nil {
		panic(err)
	}

	return item
}

// IsCasting 是否投屏中
func (r *letsviewUser) IsCasting(code int64) bool {
	if code == 0 {
		return false
	}

	// software.Redis(r.ctx).s
	return true
}
